import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './assets/css/global.css'
// 导入组件库
// import ElementUI from 'element-ui'
// import 'element-ui/lib/theme-chalk/index.css'
// Vue.use(ElementUI)

//导入nprogress
import Nprogress from 'nprogress'


// 导入axios
import axios from 'axios'
// 设置默认路径
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
// 设置axios拦截器,在request中展示进度条Nprogress.start()
axios.interceptors.request.use(config => {
  //给请求头添加 Authorization 属性。每次发请求都会带这个属性，没登录之前值是null
  config.headers.Authorization = window.sessionStorage.getItem('token')
  Nprogress.start()
  // 在最后必须return config 固定写法
  return config
})
// 在 response 拦截器中，隐藏进度条Nprogress.done()
axios.interceptors.response.use(config => {
  Nprogress.done()
  return config
})
// 将axios 挂载到vue上
Vue.prototype.$http = axios

//导入vue-table-with-tree-grid
import TreeTable from 'vue-table-with-tree-grid'
Vue.component('tree-table', TreeTable)

// 全局过滤器的使用
Vue.filter('dateFormat', function (originVal) {
  const dt = new Date(originVal)
  const y = dt.getFullYear()
  const m = (dt.getMonth() + 1 + '').padStart(2, '0')
  const d = (dt.getDate() + '').padStart(2, '0')
  const hh = (dt.getHours() + '').padStart(2, '0')
  const mm = (dt.getMinutes() + '').padStart(2, '0')
  const ss = (dt.getSeconds() + '').padStart(2, '0')
  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})

// 富文本编辑器vue-quill-editor的引入
import VueQuillEditor from 'vue-quill-editor'

Vue.use(VueQuillEditor)

Vue.config.productionTip = false
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
